<?php
/**
 * Created by PhpStorm.
 * User: 戎大富
 * Date: 2020/2/19
 * Time: 18:03
 */
namespace app\api\controller;
use think\Db;
class My extends Base {
    /**
     * 异地登录验证
     * @return string|void
     */
    public function _initialize()
    {
        header('Access-Control-Allow-Origin:*');
        extract(input());
        if($user_id != 0){
            $auth = $this->checkAll($user_id,$time,$value,$reqKey);
            if($auth == 112){
                echo json_encode(['status'=>301,'msg'=>$this->otherLogin]);
                exit;
            }elseif($auth == 110){
                echo json_encode(['status' => 302, 'msg' => $this->frost]);
                exit;
            }elseif($auth == 1103){
                echo json_encode(['status' => 303, 'msg' => $this->del]);
                exit;
            }
        }

    }

    public function userInfo(){
        extract(input());
        $where['user_id'] = $user_id;
        $res = Db::table('up_u_user')->where($where)->field('user_username,user_image')->find();
        return json(array('status'=>200,'msg'=>$res));

    }
    public function userInfoEdit(){
            extract(input());
        if(isset($username) && $username!=''){
            $data['user_username'] = $username;
        }
        if(isset($image) && $image!=''){
            $data['user_image'] = $image;
        }
        $data['user_update_time'] = date('Y-m-d H:i:s');
        $where['user_id'] = $user_id;
        $res = Db::table('up_u_user')->where($where)->update($data);
        if($res){
            return json(array('status'=>200,'msg'=>"修改成功"));
        }else{
            return json(array('status'=>0,'msg'=>"修改失败"));
        }

    }
    public function feedback(){
            extract(input());
        $data = [
            'f_user_id' => $user_id,
            'feedback_content' => $content,
            'feedback_time' => date('Y-m-d H:i:s'),
        ];
        $res = Db::table('up_feedback')->insert($data);
        if($res){
            return json(array('status'=>200,'msg'=>"成功"));
        }else{
            return json(array('status'=>0,'msg'=>"失败"));
        }

    }
}